<?php

abstract class Dcmp_Model_Spoor extends Dcmp_Model_Entity {

    public function __construct() {
        parent::__construct();
    }

    protected function beforeInsert($transaction) {
        if (!$this->issetData('creator_id')) {
            $this->setCreatorId(Kd_Web::getIdentity()->getId());
        }
        if (!$this->issetData('mender_id')) {
            $this->setMenderId(Kd_Web::getIdentity()->getId());
        }
        $this->setCreatedTime(date('Y-m-d H:i:s'));
        $this->setModifiedTime(date('Y-m-d H:i:s'));
        parent::beforeInsert($transaction);
    }

    protected function beforeUpdate($transaction) {
        $this->setMenderId(Kd_Web::getIdentity()->getId());
        $this->setModifiedTime(date('Y-m-d H:i:s'));
        parent::beforeUpdate($transaction);
    }

    protected function initializeTable($table) {
        $table->createColumn('creator_id', 'integer')->setUpdateable(FALSE);
        $table->createColumn('created_time', 'datetime')->setUpdateable(FALSE);
        $table->createColumn('modified_time', 'datetime');
        $table->createColumn('mender_id', 'integer');
    }

}